package com.op.teachingliteapp.activity;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

import com.op.teachingliteapp.R;
import com.op.teachingliteapp.fragment.cloud_class;
import com.op.teachingliteapp.fragment.cloud_disk;
import com.op.teachingliteapp.fragment.add_class.indexablelistview.IndexableListViewFragment;

public class MainActivity extends Activity {
	private TextView TopOne;
	private Button YunKeTang;
	private Button YunPan;
	private Button Set;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		System.out.println("oncreat");
		//requestWindowFeature(Window.FEATURE_NO_TITLE);//去掉标题栏
		setContentView(R.layout.activity_main_one);
		TopOne=(TextView) findViewById(R.id.top_view_one);
		
		
		if(getFragmentManager().findFragmentById(R.id.main_show)==null){
			getFragmentManager().beginTransaction().addToBackStack(null).add(R.id.main_show,new cloud_class()).commit();
		}
		
		//登录
		findViewById(R.id.load).setOnTouchListener(new OnTouchListener() {
			
			@SuppressLint("ClickableViewAccessibility")
			@Override
			public boolean onTouch(View v, MotionEvent event) {
				if(event.getAction()==MotionEvent.ACTION_DOWN){
					//保留有用，不要删
				}
				if(event.getAction()==MotionEvent.ACTION_UP){
					Toast.makeText(getApplicationContext(), "登录", Toast.LENGTH_SHORT).show();
				}
				return false;
			}
		});
		
		
		
		
		
		//云课堂
		YunKeTang=(Button) findViewById(R.id.buttom_home);
		YunKeTang.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				TopOne.setText("课程选择");
				YunKeTang.setBackgroundResource(R.drawable.buttom_home2);
				YunPan.setBackgroundResource(R.drawable.buttom_cloud3);
				Set.setBackgroundResource(R.drawable.buttom_set3);
				getFragmentManager().beginTransaction().addToBackStack(null).replace(R.id.main_show, new cloud_class()).commit();

			}
		} );
		
		//云盘
		YunPan=(Button) findViewById(R.id.buttom_cloud3);
		YunPan.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				TopOne.setText("云盘");
				YunPan.setBackgroundResource(R.drawable.buttom_cloud2);
				YunKeTang.setBackgroundResource(R.drawable.buttom_home3);
				Set.setBackgroundResource(R.drawable.buttom_set3);
				Toast.makeText(getApplicationContext(), "冲哥正在熬夜开发", Toast.LENGTH_SHORT).show();
				getFragmentManager().beginTransaction().addToBackStack(null).replace(R.id.main_show, new cloud_disk()).commit();
			}
		});
		
		
		//设置
		Set= (Button) findViewById(R.id.buttom_set3);
		Set.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				TopOne.setText("设置");
				Set.setBackgroundResource(R.drawable.buttom_set2);
				YunKeTang.setBackgroundResource(R.drawable.buttom_home3);
				YunPan.setBackgroundResource(R.drawable.buttom_cloud3);
				Toast.makeText(getApplicationContext(), "设置界面不明", Toast.LENGTH_SHORT).show();
				
			}
		});
		
//		 findViewById(R.id.buttom_set3).setOnTouchListener(new OnTouchListener() {
//			
//			@SuppressLint("ClickableViewAccessibility")
//			@Override
//			public boolean onTouch(View v, MotionEvent event) {
//				if(event.getAction()==MotionEvent.ACTION_DOWN){
//					YunKeTang.setBackgroundResource(R.drawable.buttom_home3);//鏀句笂
//					YunPan.setBackgroundResource(R.drawable.buttom_cloud3);//鏀句笂	
//					findViewById(R.id.buttom_set3).setBackgroundResource(R.drawable.buttom_set2);//闀挎憗
//				}
//				if(event.getAction()==MotionEvent.ACTION_UP){
//					Toast.makeText(getApplicationContext(), "璁剧疆鐣岄潰涓嶆槑", Toast.LENGTH_SHORT).show();
//					findViewById(R.id.buttom_set3).setBackgroundResource(R.drawable.buttom_set1);//
//				}
//				return false;
//			}
//		});
		
		
		
		
		
	}
	
	/*
	 * 锁定虚拟返回键
	 */
	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		
		return false;
	}
	
	
	
	@Override
	protected void onStart() {
		System.out.println("stop");
		super.onStart();
	}
	@Override
	protected void onDestroy() {
		System.out.println("out");
		super.onDestroy();
	}
}
